import { ButtonProps } from "element-plus";
import { ComputedRef, VNodeChild } from "vue";

// @ts-ignore
export interface ModalProps {
  // 是否显示 Dialog
  modelValue: boolean;
  // Dialog 自身是否插入至 body 元素上。 嵌套的 Dialog 必须指定该属性并赋值为 true
  appendToBody?: boolean;
  // 当关闭 Dialog 时，销毁其中的元素
  destroyOnClose?: boolean;
  // 是否可以通过点击 modal 关闭 Dialog
  closeOnClickModal?: boolean;
  // 是否可以通过按下 ESC 关闭 Dialog
  closeOnPressEscape?: boolean;
  // 是否在 Dialog 出现时将 body 滚动锁定
  lockScroll?: boolean;
  // 是否需要遮罩层
  modal?: boolean;
  // Dialog 打开的延时时间，单位毫秒
  openDelay?: number;
  // Dialog 关闭的延时时间，单位毫秒
  closeDelay?: number;
  // Dialog CSS 中的 margin-top 值
  top?: string;
  modalClass?: string;
  width?: string | number;
  zIndex?: number;
  trapFocus?: boolean;
  center?: boolean;
  closeIcon?: VNodeChild | JSX.Element;
  customClass?: string;
  draggable?: boolean;
  fullscreen?: boolean;
  showClose?: boolean;
  title?: string;

  // 是否可以进行全屏
  canFullscreen?: boolean;
  scrollTop?: boolean;
  height?: number;
  minHeight?: number;

  /**
   * Text of the Cancel button
   * @default 'cancel'
   * @type string
   */
  cancelText?: string;
  /**
   * Text of the OK button
   * @default 'OK'
   * @type string
   */
  okText?: string;
  closeFunc: () => Promise<any>;
  confirmLoading?: boolean;

  // 温馨提醒信息
  helpMessage: string | string[];

  // 是否使用modalWrapper
  useWrapper: boolean;

  loading: boolean;
  loadingTip?: string;

  showOkBtn: boolean;
  showCancelBtn: boolean;
  okType: BtnType



  cancelButtonProps: ButtonProps
  okButtonProps: ButtonProps

}

export type BtnType = "" | "default" | "primary" | "success" | "warning" | "info" | "danger" | "text" | undefined
/**
 * @description: 弹窗对外暴露的方法
 */
export interface ModalMethods {
  setModalProps: (props: Partial<ModalProps>) => void;
  emitVisible?: (visible: boolean, uid: number) => void;
}
export type RegisterFn = (modalMethods: ModalMethods, uuid: string) => void;

export interface ReturnMethods extends ModalMethods {
  openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void;
  closeModal: () => void;
  getVisible?: ComputedRef<boolean>;
  changeLoading: (loading: boolean) => void;
  changeOkLoading: (loading: boolean) => void;
}

export type UseModalReturnType = [RegisterFn, ReturnMethods];

export interface ReturnInnerMethods extends ModalMethods {
  closeModal: () => void;
  getVisible?: ComputedRef<boolean>;
}

export type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods];
